package com.example.coursemanagement.controller;


import com.example.coursemanagement.MyUtils.CommonResult;
import com.example.coursemanagement.pojo.Campus_comments;
import com.example.coursemanagement.service.ICampusCommentsService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yangmenghen
 * @since 2020-06-01
 */
@RestController
@RequestMapping("/campusComments" )
@RequiredArgsConstructor
public class CampusCommentsController {

    @Autowired
    private ICampusCommentsService commentsService;

    @ApiOperation("发布评论")
    @PostMapping("/publishComments")
    public CommonResult<Object> publishComments(@RequestBody Campus_comments campus_comments){
        return commentsService.publishComments(campus_comments);
    }

    @ApiOperation("修改评论")
    @PutMapping("/updateComments")
    public CommonResult<Object> updateComments(@RequestBody Campus_comments campus_comments){
        return commentsService.updateComments(campus_comments);
    }

    @ApiOperation("删除评论")
    @DeleteMapping("/deleteCommentsById")
    public CommonResult<Object> deleteCommentsById(@RequestParam("commentId")Integer commentId){
        return commentsService.deleteCommentsById(commentId);
    }

    @ApiOperation("根据用户id查询评论")
    @GetMapping("/selectCommentsByUserId")
    public CommonResult<Object> selectCommentsByUserId(@RequestParam("userId")Integer userId){
        return commentsService.selectCommentsByUserId(userId);
    }

    @ApiOperation("根据校园资讯id查询评论")
    @GetMapping("/selectCommentsByCampusId")
    public CommonResult<Object> selectCommentsByCampusId(@RequestParam("campusId")Integer campusId){
        return commentsService.selectCommentsByCampusId(campusId);
    }


}

